import java.util.*;

/**
 * @author LKQ
 * @date 2022/3/21 9:24
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] arr = {0,2,1,-6,6,-7,9,1,2,0,1};
        solution.canThreePartsEqualSum(arr);
    }
    public boolean canThreePartsEqualSum(int[] arr) {
        int n = arr.length;
        int[] left = new int[n + 1];
        int[] right = new int[n + 1];
        for (int i = 0; i < n; i++) {
            left[i + 1] = left[i] + arr[i];
            right[n-i-1] = right[n-i] + arr[n-i-1];
        }
        for (int i = 0; i < n; i++) {
            int leftSum = left[i + 1];
            for (int j = i + 2; j < n; j++) {
                if (leftSum == right[j] && leftSum == left[n] - leftSum - right[j]) {
                    return true;
                }
            }
        }
        return false;
    }
}
